using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using GonzalesCore.CoreElements;
using GonzalesCore.CoreManagers;
using Kypris2.CoreElements;
using Kypris2.Utils;
using Jamila2.Tools;

public partial class GonzalesAdminMain : System.Web.UI.Page
{
    protected PrivateLoginSession CurrentPrivateSession = null;
    protected LogManager CurLogManager = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        this.SessionCheck();

        this.PageComponentSetup();
        this.SwitchLanguage();

        // user right
        this.HyperLink_ClaimantDetailSetting.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.HyperLink_ExpenseDetailLimit.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.HyperLink_ExceptionalApprovingSetting.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
      //this.HyperLink_AuthorizersSetting.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.HyperLink_AuthorizersSetting.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager);
        this.HyperLink_FinanceAdminSetting.Enabled = this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager;
        //this.HyperLink_FinanceAdminSetting.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        //this.HyperLink_FinanceApprover.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.HyperLink_FinanceApprover.Enabled = this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager;

        this.HyperLink_CompanySetting.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.HyperLink_TestEmail.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsITAdmin);
        this.HyperLink_ErrorLog.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsITAdmin);
        this.HyperLink_GeneralActionLog.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsITAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager);
        this.HyperLink_AdminPanel.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin);        

        this.HyperLink_EntityBasedSetup.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.HyperLink_LanguageTranslation.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);

        // style
        this.HyperLink_ClaimantDetailSetting.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_ExpenseDetailLimit.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_ExceptionalApprovingSetting.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin ) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_AuthorizersSetting.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_FinanceAdminSetting.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_FinanceApprover.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";

        this.HyperLink_CompanySetting.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_TestEmail.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsITAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_ErrorLog.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsITAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_GeneralActionLog.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsITAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_AdminPanel.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin) ? "GridViewLink" : "GridViewLinkDisabled";        

        this.HyperLink_EntityBasedSetup.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.HyperLink_LanguageTranslation.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";

    }

    #region Customized Methods

    #region SessionCheck
    public void SessionCheck()
    {
        if (Session[GonzalesCommonNamingConvention.CurrentPrivateSession] != null)
        {
            this.CurrentPrivateSession = (PrivateLoginSession)Session[GonzalesCommonNamingConvention.CurrentPrivateSession];
            this.CurLogManager = new LogManager(this.CurrentPrivateSession);    // activate Log Manager

            if (!this.CurrentPrivateSession.CurrentLoggedOnUser.IsAdmin)
            {
                Response.Redirect(GonzalesErrorPageRedirect.SessionError);
            }
        }
        else
        {
            Response.Redirect(GonzalesErrorPageRedirect.SessionError);
        }

    }
    #endregion

    #region PageComponentSetup
    protected void PageComponentSetup()
    {

    }
    #endregion

    #region SwitchLanguage
    protected void SwitchLanguage()
    {
        try
        {
            using (MultiLingualFactory CurLanguageFactory = MultiLingualEngine.GetMultiLingualFactory(this, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedLanguage.InternalID))
            {
                this.Label_PageTitle.Text = CurLanguageFactory.DisplayValue("PageTitle");
                this.Label_ExpenseDetail.Text = CurLanguageFactory.DisplayValue("ExpenseDetail");
                this.Label_Information.Text = CurLanguageFactory.DisplayValue("Information");
                this.Label_Personnel.Text = CurLanguageFactory.DisplayValue("Personnel");
                this.Label_Personnel2.Text = CurLanguageFactory.DisplayValue("Personnel2");
                this.Label_Personnel3.Text = CurLanguageFactory.DisplayValue("Personnel3");
                this.HyperLink_AccrualReport.Text = CurLanguageFactory.DisplayValue("AccrualReport");
                this.HyperLink_AdminPanel.Text = CurLanguageFactory.DisplayValue("AdminPanel");
                this.HyperLink_AuthorizersSetting.Text = CurLanguageFactory.DisplayValue("AuthorizersSetting");
                this.HyperLink_ClaimantDetailSetting.Text = CurLanguageFactory.DisplayValue("ClaimantDetailSetting");
                this.HyperLink_CompanySetting.Text = CurLanguageFactory.DisplayValue("CompanySetting");
                this.HyperLink_CreditCardReport.Text = CurLanguageFactory.DisplayValue("CreditCardReport");
                this.HyperLink_EntityBasedSetup.Text = CurLanguageFactory.DisplayValue("EntityBasedSetup");
                this.HyperLink_ErrorLog.Text = CurLanguageFactory.DisplayValue("ErrorLog");
                this.HyperLink_ExceptionalApprovingSetting.Text = CurLanguageFactory.DisplayValue("ExceptionalApprovingSetting");
                this.HyperLink_ExpenseDetailLimit.Text = CurLanguageFactory.DisplayValue("ExpenseDetailLimit");
                this.HyperLink_FinanceAdminSetting.Text = CurLanguageFactory.DisplayValue("FinanceAdminSetting");
                this.HyperLink_FinanceApprover.Text = CurLanguageFactory.DisplayValue("FinanceApprover");
                this.HyperLink_GeneralActionLog.Text = CurLanguageFactory.DisplayValue("GeneralActionLog");
                this.HyperLink_Guide1.Text = CurLanguageFactory.DisplayValue("Guide1");
                this.HyperLink_LanguageTranslation.Text = CurLanguageFactory.DisplayValue("LanguageTranslation");
                this.HyperLink_ReportActiveExpenseDetail.Text = CurLanguageFactory.DisplayValue("ReportActiveExpenseDetail");
                this.HyperLink_ReportGeneralClaimant.Text = CurLanguageFactory.DisplayValue("ReportGeneralClaimant");
                this.HyperLink_ReportGeneralClaims.Text = CurLanguageFactory.DisplayValue("ReportGeneralClaims");
                this.HyperLink_TestEmail.Text = CurLanguageFactory.DisplayValue("TestEmail");
                this.HyperLink_ChangeStatus.Text = CurLanguageFactory.DisplayValue("ChangeStatus");
                this.HyperLink_ApproverReplacement.Text = CurLanguageFactory.DisplayValue("ApproverReplacment");
            }
        }
        catch (Exception ex)
        {
            this.CurLogManager.LogError("[GonzalesAdminClaimantsDetail.SwitchLanguage.EX] : " + ex.Message, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.User);
        }

    }
    #endregion

    #endregion
}